{{if false}}<script>{{/if}}
var myjqxGrid= (function () {
        var myGrid=$("#jqxGrid");
        var theme="classic";
        var source ={
            datatype: "json",
            type        :   "POST",
            datafields  : [
                { name: '_id'   , type: 'int' },
                { name: '_table', type: 'string' },
                { name: '_row'  , type: 'string' },
                { name: '_commandtype'  , type: 'string' },
                { name: '_insert'  , type: 'string' },
                { name: '_log'  , type: 'string' }
            ],
            url         : '{{base_url()}}backend/log/binding/',
            filter      : function(){ 
                myGrid.jqxGrid('updatebounddata', 'filter') 
            },
            sort        : function(){ 
                myGrid.jqxGrid('updatebounddata') 
            },
            root        : 'Rows',
            beforeprocessing: function(data){		
                    source.totalrecords = data[0].TotalRows;					
            }
        };	
        var dataadapter = new $.jqx.dataAdapter(source, {
            loadError: function(xhr, status, error){
                tipMessage("<b>Status</b>:"+xhr.status+"<br/><b>ThrownError</b>:"+error+"<br/>");
            }
        });
        var columns=[
            { text: 'ID'        , datafield: '_id', width: 80,hidden:true},
            { text: 'Table'     , datafield: '_table'},
            { text: 'Command'   , datafield: '_commandtype'},
            { text: 'Insert'    , datafield: '_insert'},
            
        ];
        function _createGrid(){
            try{
                var gridconfig={
                    width:'100%',
                    source: dataadapter,
                    theme: theme,
                    sortable: true,
                    rendergridrows: function(obj)
                    {
                        return obj.data;    
                    },
                    filterable: true,
                    autoshowfiltericon: true,
                    showfilterrow: true,
                    height:($(document).height() - 140)>500?($(document).height() - 140):500,
                    //virtualmode: true,
                    columns: columns,
                    pageable :    true,
                    pagesize :   100,
                    pagesizeoptions  :   ['50','100', '200', '500' , '1000']
                };
                myGrid.jqxGrid(gridconfig)
                .bind('rowselect', function (event) {
                    try{
                        event.args.rowindex;
                        var rowData=$("#jqxGrid").jqxGrid('getrowdata', event.args.rowindex);
                        var _log = rowData._log;
                        $("#_logs").html(_log);
                    }catch(e){ uiMessage(e.message); }
                });
                //handleEvent_jqxGrid(myGrid);
            }catch(e){ uiMessage(e.message); }
        }
        return {
            Init:function(){
                _createGrid();
            }
        }
    } ());
    $(document).ready(function () {
        myjqxGrid.Init();
    });